package com.dhecp.project.logstics.service.impl;

import com.alibaba.fastjson.JSON;
import com.dhecp.common.utils.IpUtils;
import com.dhecp.core.constant.DataFiltering;
import com.dhecp.core.utils.PageUtils;
import com.dhecp.project.business.domain.FbaLogsticsOrderBox;
import com.dhecp.project.business.domain.FbaLogsticsOrderBoxTol;
import com.dhecp.project.common.service.impl.BaseModuleServiceImpl;
import com.dhecp.project.logstics.mapper.FbaLogsticsOrderBoxMapper;
import com.dhecp.project.logstics.service.FbaLogsticsOrderBoxService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @Author fxz
 * @Date 2022/10/27
 */
@Service
public class FbaLogsticsOrderBoxServicelmpl extends BaseModuleServiceImpl implements FbaLogsticsOrderBoxService {

    @Autowired
    private FbaLogsticsOrderBoxMapper fbaLogsticsOrderBoxMapper;
    
    /**
     * 查询头程计划单
     * @param params
     * @return
     * @throws Exception
     */
    @Override
    public List<FbaLogsticsOrderBox> queryList(Map<String, Object> params) throws Exception {
        //获取当前装箱单有多少头程订单
        List<FbaLogsticsOrderBox> queryList = new ArrayList<>();
        //头程计划单下所有箱子数据
        List<FbaLogsticsOrderBox> fbaLogsticsOrderBoxList = fbaLogsticsOrderBoxMapper.findFbaLogsticsOrderBox(params);

        //FbaLogsticsOrderBoxList为空新增  反之修改
        List<FbaLogsticsOrderBox> fbaLogsticsOrderBoxListNew = null;
        String numRealityDeliver;
        String numRealityDeliver1;
        //总的数量值
        FbaLogsticsOrderBoxTol fbaLogsticsOrderBoxTol = new FbaLogsticsOrderBoxTol();
        if (fbaLogsticsOrderBoxList.size() > 0){
            //取出每条箱子的商品数据将箱数赋值到对应的箱子数据上
            for (int j = 0; j < fbaLogsticsOrderBoxList.size(); j++) {
                fbaLogsticsOrderBoxListNew = JSON.parseArray(fbaLogsticsOrderBoxList.get(j).getProductInfo(), FbaLogsticsOrderBox.class);
                for (int i = 0; i < fbaLogsticsOrderBoxListNew.size(); i++) {
                    if (j == 0) {
                        switch (j) {
                            case 0:
                                fbaLogsticsOrderBoxListNew.get(i).setNumRealityDeliver1(fbaLogsticsOrderBoxListNew.get(i).getNumRealityDeliver());
                                break;
                            case 1:
                                fbaLogsticsOrderBoxListNew.get(i).setNumRealityDeliver2(fbaLogsticsOrderBoxListNew.get(i).getNumRealityDeliver());
                                break;
                            case 2:
                                fbaLogsticsOrderBoxListNew.get(i).setNumRealityDeliver3(fbaLogsticsOrderBoxListNew.get(i).getNumRealityDeliver());
                                break;
                            case 3:
                                fbaLogsticsOrderBoxListNew.get(i).setNumRealityDeliver4(fbaLogsticsOrderBoxListNew.get(i).getNumRealityDeliver());
                                break;
                            case 4:
                                fbaLogsticsOrderBoxListNew.get(i).setNumRealityDeliver5(fbaLogsticsOrderBoxListNew.get(i).getNumRealityDeliver());
                                break;
                            case 5:
                                fbaLogsticsOrderBoxListNew.get(i).setNumRealityDeliver6(fbaLogsticsOrderBoxListNew.get(i).getNumRealityDeliver());
                                break;
                            case 6:
                                fbaLogsticsOrderBoxListNew.get(i).setNumRealityDeliver7(fbaLogsticsOrderBoxListNew.get(i).getNumRealityDeliver());
                                break;
                            case 7:
                                fbaLogsticsOrderBoxListNew.get(i).setNumRealityDeliver8(fbaLogsticsOrderBoxListNew.get(i).getNumRealityDeliver());
                                break;
                            case 8:
                                fbaLogsticsOrderBoxListNew.get(i).setNumRealityDeliver9(fbaLogsticsOrderBoxListNew.get(i).getNumRealityDeliver());
                                break;
                            case 9:
                                fbaLogsticsOrderBoxListNew.get(i).setNumRealityDeliver10(fbaLogsticsOrderBoxListNew.get(i).getNumRealityDeliver());
                                break;
                        }
                    } else {
                        numRealityDeliver = fbaLogsticsOrderBoxListNew.get(i).getNumRealityDeliver().equals("")?"0":fbaLogsticsOrderBoxListNew.get(i).getNumRealityDeliver();
                        numRealityDeliver1 = queryList.get(i).getNumRealityDeliver().equals("")?"0":queryList.get(i).getNumRealityDeliver();
                        queryList.get(i).setNumRealityDeliver(
                                String.valueOf(new Integer(numRealityDeliver1)
                                        + new Integer(numRealityDeliver)));
                        switch (j) {
                            case 1:
                                queryList.get(i).setNumRealityDeliver2(fbaLogsticsOrderBoxListNew.get(i).getNumRealityDeliver());
                                break;
                            case 2:
                                queryList.get(i).setNumRealityDeliver3(fbaLogsticsOrderBoxListNew.get(i).getNumRealityDeliver());
                                break;
                            case 3:
                                queryList.get(i).setNumRealityDeliver4(fbaLogsticsOrderBoxListNew.get(i).getNumRealityDeliver());
                                break;
                            case 4:
                                queryList.get(i).setNumRealityDeliver5(fbaLogsticsOrderBoxListNew.get(i).getNumRealityDeliver());
                                break;
                            case 5:
                                queryList.get(i).setNumRealityDeliver6(fbaLogsticsOrderBoxListNew.get(i).getNumRealityDeliver());
                                break;
                            case 6:
                                queryList.get(i).setNumRealityDeliver7(fbaLogsticsOrderBoxListNew.get(i).getNumRealityDeliver());
                                break;
                            case 7:
                                queryList.get(i).setNumRealityDeliver8(fbaLogsticsOrderBoxListNew.get(i).getNumRealityDeliver());
                                break;
                            case 8:
                                queryList.get(i).setNumRealityDeliver9(fbaLogsticsOrderBoxListNew.get(i).getNumRealityDeliver());
                                break;
                            case 9:
                                queryList.get(i).setNumRealityDeliver10(fbaLogsticsOrderBoxListNew.get(i).getNumRealityDeliver());
                                break;
                        }
                    }
                    if (j == 0) {
                        queryList.add(fbaLogsticsOrderBoxListNew.get(i));
                    }
                }
            }

            //进行排序（naturalOrder 正序）（reverseOrder倒叙）
            queryList = queryList.stream().
                    sorted(Comparator.comparing(FbaLogsticsOrderBox::getCommodityCode, Comparator.naturalOrder())).
                    sorted(Comparator.comparing(FbaLogsticsOrderBox::getCodeStockLocation, Comparator.naturalOrder())).
                    sorted(Comparator.comparing(FbaLogsticsOrderBox::getCodeStockArea, Comparator.naturalOrder())).
                    sorted(Comparator.comparing(FbaLogsticsOrderBox::getCodeStockOn, Comparator.naturalOrder())).
                    collect(Collectors.toList());
        }

        //合计栏数据
        for (FbaLogsticsOrderBox fbaLogsticsOrderBox : queryList){
            fbaLogsticsOrderBoxTol.setNumPlanDeliver(String.valueOf(new Integer(fbaLogsticsOrderBoxTol.getNumPlanDeliver()) + new Integer(fbaLogsticsOrderBox.getNumPlanDeliver())));
            fbaLogsticsOrderBoxTol.setNumRealityDeliver(String.valueOf(new Integer(fbaLogsticsOrderBoxTol.getNumRealityDeliver()) + (fbaLogsticsOrderBox.getNumRealityDeliver().equals("")?0:new Integer(fbaLogsticsOrderBox.getNumRealityDeliver()))));
            fbaLogsticsOrderBoxTol.setNumRealityDeliver1(String.valueOf(new Integer(fbaLogsticsOrderBoxTol.getNumRealityDeliver1()) + (fbaLogsticsOrderBox.getNumRealityDeliver1().equals("")?0:new Integer(fbaLogsticsOrderBox.getNumRealityDeliver1()))));
            fbaLogsticsOrderBoxTol.setNumRealityDeliver2(String.valueOf(new Integer(fbaLogsticsOrderBoxTol.getNumRealityDeliver2()) + (fbaLogsticsOrderBox.getNumRealityDeliver2().equals("")?0:new Integer(fbaLogsticsOrderBox.getNumRealityDeliver2()))));
            fbaLogsticsOrderBoxTol.setNumRealityDeliver3(String.valueOf(new Integer(fbaLogsticsOrderBoxTol.getNumRealityDeliver3()) + (fbaLogsticsOrderBox.getNumRealityDeliver3().equals("")?0:new Integer(fbaLogsticsOrderBox.getNumRealityDeliver3()))));
            fbaLogsticsOrderBoxTol.setNumRealityDeliver4(String.valueOf(new Integer(fbaLogsticsOrderBoxTol.getNumRealityDeliver4()) + (fbaLogsticsOrderBox.getNumRealityDeliver4().equals("")?0:new Integer(fbaLogsticsOrderBox.getNumRealityDeliver4()))));
            fbaLogsticsOrderBoxTol.setNumRealityDeliver5(String.valueOf(new Integer(fbaLogsticsOrderBoxTol.getNumRealityDeliver5()) + (fbaLogsticsOrderBox.getNumRealityDeliver5().equals("")?0:new Integer(fbaLogsticsOrderBox.getNumRealityDeliver5()))));
            fbaLogsticsOrderBoxTol.setNumRealityDeliver6(String.valueOf(new Integer(fbaLogsticsOrderBoxTol.getNumRealityDeliver6()) + (fbaLogsticsOrderBox.getNumRealityDeliver6().equals("")?0:new Integer(fbaLogsticsOrderBox.getNumRealityDeliver6()))));
            fbaLogsticsOrderBoxTol.setNumRealityDeliver7(String.valueOf(new Integer(fbaLogsticsOrderBoxTol.getNumRealityDeliver7()) + (fbaLogsticsOrderBox.getNumRealityDeliver7().equals("")?0:new Integer(fbaLogsticsOrderBox.getNumRealityDeliver7()))));
            fbaLogsticsOrderBoxTol.setNumRealityDeliver8(String.valueOf(new Integer(fbaLogsticsOrderBoxTol.getNumRealityDeliver8()) + (fbaLogsticsOrderBox.getNumRealityDeliver8().equals("")?0:new Integer(fbaLogsticsOrderBox.getNumRealityDeliver8()))));
            fbaLogsticsOrderBoxTol.setNumRealityDeliver9(String.valueOf(new Integer(fbaLogsticsOrderBoxTol.getNumRealityDeliver9()) + (fbaLogsticsOrderBox.getNumRealityDeliver9().equals("")?0:new Integer(fbaLogsticsOrderBox.getNumRealityDeliver9()))));
            fbaLogsticsOrderBoxTol.setNumRealityDeliver10(String.valueOf(new Integer(fbaLogsticsOrderBoxTol.getNumRealityDeliver9()) + (fbaLogsticsOrderBox.getNumRealityDeliver10().equals("")?0:new Integer(fbaLogsticsOrderBox.getNumRealityDeliver10()))));
        }

        FbaLogsticsOrderBox fbaLogsticsOrderBox;
        int tag = 0;
        //1.装箱 2.发货
        int num = Integer.parseInt(params.get("num").toString());
        if (num == 1){
            tag = 7;
        } else if (num == 2){
            tag = 7;
        } else if (num ==3){
            tag = 8;
        }else if (num ==0){
            tag = 5;
        }

        String serial = "";
        for (int i = 0; i < tag; i++) {
            fbaLogsticsOrderBox = new FbaLogsticsOrderBox();
            switch (i) {
                case 0:
                    serial = "合计";
                    break;
                case 1:
                    serial = "箱重(kg)";
                    break;
                case 2:
                    serial = "箱规长(cm)";
                    break;
                case 3:
                    serial = "箱规宽(cm)";
                    break;
                case 4:
                    serial = "箱规高(cm)";
                    break;
                case 5:
                    serial = "抛重(kg)";
                    break;
                case 6:
                    serial = "单箱采购总价(￥)";
                    break;
                case 7:
                    serial = "追踪编号";
                    break;
            }
            //添加箱重/长宽高等数据
            addJx(fbaLogsticsOrderBoxList,fbaLogsticsOrderBox,i,fbaLogsticsOrderBoxTol);

            fbaLogsticsOrderBox.setScrapData("1");
            fbaLogsticsOrderBox.setSerial(serial);
            queryList.add(fbaLogsticsOrderBox);
        }
        return queryList;
    }

    /**
     * 查询自动头程计划单
     * @param params
     * @return
     * @throws Exception
     */
    @Override
    public List<FbaLogsticsOrderBox> queryAutoList(Map<String, Object> params) throws Exception {

        //获取当前装箱单有多少头程订单
        List<FbaLogsticsOrderBox> queryList = new ArrayList<>();
        //头程计划单下所有箱子数据
        List<FbaLogsticsOrderBox> fbaLogsticsOrderBoxList = fbaLogsticsOrderBoxMapper.findFbaLogsticsOrderBox(params);

        //FbaLogsticsOrderBoxList为空新增  反之修改
        List<FbaLogsticsOrderBox> fbaLogsticsOrderBoxListNew = null;
        String numRealityDeliver;
        String numRealityDeliver1;
        //总的数量值
        FbaLogsticsOrderBoxTol fbaLogsticsOrderBoxTol = new FbaLogsticsOrderBoxTol();
        Map<String,List<BigDecimal>> boxListMap = new HashMap<>();
        List<BigDecimal> boxList;
        List<BigDecimal> boxListTol;

        int tag = 0;
        //1.装箱 2.发货
        int num = Integer.parseInt(params.get("num").toString());
        if (num == 1){
            tag = 7;
        } else if (num == 2){
            tag = 7;
        } else if (num ==3){
            tag = 8;
        }else if (num ==0){
            tag = 5;
        }
        if (fbaLogsticsOrderBoxList.size() > 0){
            queryList = new ArrayList<>();
            //取出每条箱子的商品数据将箱数赋值到对应的箱子数据上
            for (int j = 0; j < fbaLogsticsOrderBoxList.size(); j++) {
                fbaLogsticsOrderBoxListNew = JSON.parseArray(fbaLogsticsOrderBoxList.get(j).getProductInfo(), FbaLogsticsOrderBox.class);
                for (int i = 0; i < fbaLogsticsOrderBoxListNew.size(); i++) {
                    boxList = new LinkedList<>();
                    if (j != 0) {
                        //计算商品的计划数量和实际数量
                        numRealityDeliver = fbaLogsticsOrderBoxListNew.get(i).getNumRealityDeliver().equals("") ? "0" : fbaLogsticsOrderBoxListNew.get(i).getNumRealityDeliver();
                        numRealityDeliver1 = queryList.get(i).getNumRealityDeliver().equals("")?"0":queryList.get(i).getNumRealityDeliver();
                        queryList.get(i).setNumRealityDeliver(
                                String.valueOf(new Integer(numRealityDeliver1)
                                        + new Integer(numRealityDeliver)));
                    }
                    //将每个商品的箱子数据按照数组形式存储起来
                    if (boxListMap.get(fbaLogsticsOrderBoxListNew.get(i).getSerial()) == null) {
                        boxList.add(new BigDecimal(fbaLogsticsOrderBoxListNew.get(i).getNumRealityDeliver()));
                        boxListMap.put(fbaLogsticsOrderBoxListNew.get(i).getSerial(), boxList);
                    } else {
                        boxList = boxListMap.get(fbaLogsticsOrderBoxListNew.get(i).getSerial());
                        if (fbaLogsticsOrderBoxListNew.get(i).getNumRealityDeliver().equals("")) {
                            boxList.add(BigDecimal.ZERO);
                        } else {
                            boxList.add(new BigDecimal(fbaLogsticsOrderBoxListNew.get(i).getNumRealityDeliver()));
                        }
                        boxListMap.put(fbaLogsticsOrderBoxListNew.get(i).getSerial(), boxList);
                    }
                    if (j == 0) {
                        fbaLogsticsOrderBoxListNew.get(i).setBoxList("");
                        queryList.add(fbaLogsticsOrderBoxListNew.get(i));
                    }
                }

                //箱重-追踪编号的每箱的数据设置进数组中
                String serial = "";
                String val = "";
                for (int i = 1; i < tag; i++) {
                    boxListTol = new LinkedList<>();
                    switch (i) {
                        case 1:
                            boxListTol.add(new BigDecimal(fbaLogsticsOrderBoxList.get(j).getWeight()));
                            val = fbaLogsticsOrderBoxList.get(j).getWeight();
                            serial = "箱重(kg)";
                            break;
                        case 2:
                            serial = "箱规长(cm)";
                            boxListTol.add(new BigDecimal(fbaLogsticsOrderBoxList.get(j).getLength()));
                            val = fbaLogsticsOrderBoxList.get(j).getLength();
                            break;
                        case 3:
                            serial = "箱规宽(cm)";
                            boxListTol.add(new BigDecimal(fbaLogsticsOrderBoxList.get(j).getWidth()));
                            val = fbaLogsticsOrderBoxList.get(j).getWidth();
                            break;
                        case 4:
                            serial = "箱规高(cm)";
                            boxListTol.add(new BigDecimal(fbaLogsticsOrderBoxList.get(j).getHeight()));
                            val = fbaLogsticsOrderBoxList.get(j).getHeight();
                            break;
                        case 5:
                            serial = "抛重(kg)";
                            boxListTol.add(new BigDecimal(fbaLogsticsOrderBoxList.get(j).getWeightVol()));
                            val = fbaLogsticsOrderBoxList.get(j).getWeightVol();
                            break;
                        case 6:
                            serial = "单箱采购总价(￥)";
                            boxListTol.add(fbaLogsticsOrderBoxList.get(j).getPriceSingleBoxReq());
                            val = String.valueOf(fbaLogsticsOrderBoxList.get(j).getPriceSingleBoxReq());
                            break;
                        case 7:
                            serial = "追踪编号";
                            if (fbaLogsticsOrderBoxList.get(j).getTrackingCode() == null){
                                boxListTol.add(BigDecimal.ZERO);
                                val = "0";
                            }else {
                                boxListTol.add(new BigDecimal(fbaLogsticsOrderBoxList.get(j).getTrackingCode()));
                                val = fbaLogsticsOrderBoxList.get(j).getTrackingCode();
                            }
                            break;
                    }
                    if (j == 0) {
                        boxListMap.put(serial, boxListTol);
                    } else {
                        boxListTol = boxListMap.get(serial);
                        if (val.equals("")) {
                            boxListTol.add(BigDecimal.ZERO);
                        } else {
                            boxListTol.add(new BigDecimal(val));
                        }
                        boxListMap.put(serial, boxListTol);
                    }
                }
            }

            //进行排序（naturalOrder 正序）（reverseOrder倒叙）
            queryList = queryList.stream().
                    sorted(Comparator.comparing(FbaLogsticsOrderBox::getCommodityCode, Comparator.naturalOrder())).
                    sorted(Comparator.comparing(FbaLogsticsOrderBox::getCodeStockLocation, Comparator.naturalOrder())).
                    sorted(Comparator.comparing(FbaLogsticsOrderBox::getCodeStockArea, Comparator.naturalOrder())).
                    sorted(Comparator.comparing(FbaLogsticsOrderBox::getCodeStockOn, Comparator.naturalOrder())).
                    collect(Collectors.toList());

            Map<String,BigDecimal> boxListMapTol = new HashMap<>();
            //合计栏数据
            for (FbaLogsticsOrderBox fbaLogsticsOrderBox : queryList){
                fbaLogsticsOrderBox.setBoxList(boxListMap.get(fbaLogsticsOrderBox.getSerial()).toString());
                fbaLogsticsOrderBoxTol.setNumPlanDeliver(String.valueOf(new Integer(fbaLogsticsOrderBoxTol.getNumPlanDeliver()) + new Integer(fbaLogsticsOrderBox.getNumPlanDeliver())));
                fbaLogsticsOrderBoxTol.setNumRealityDeliver(String.valueOf(new Integer(fbaLogsticsOrderBoxTol.getNumRealityDeliver()) + (fbaLogsticsOrderBox.getNumRealityDeliver().equals("")?0:new Integer(fbaLogsticsOrderBox.getNumRealityDeliver()))));
                for (int i = 0; i < boxListMap.get(fbaLogsticsOrderBox.getSerial()).size(); i++) {
                    if (boxListMapTol.get(String.valueOf(i)) == null){
                        boxListMapTol.put(String.valueOf(i),boxListMap.get(fbaLogsticsOrderBox.getSerial()).get(i));
                    }else {
                        if (boxListMapTol.get(String.valueOf(i)).equals("")){
                            boxListMapTol.put(String.valueOf(i),BigDecimal.ZERO);
                        }else {
                            boxListMapTol.put(String.valueOf(i),boxListMapTol.get(String.valueOf(i)).add(boxListMap.get(fbaLogsticsOrderBox.getSerial()).get(i)));
                        }
                    }
                }
            }

            //设置合计数据
            boxList = new LinkedList<>();
            for(Map.Entry entry : boxListMapTol.entrySet()){
                boxList.add((BigDecimal) entry.getValue());
            }
            fbaLogsticsOrderBoxTol.setBoxList(boxList.toString());
        }



        FbaLogsticsOrderBox fbaLogsticsOrderBox;


        String serial = "";
        for (int i = 0; i < tag; i++) {
            fbaLogsticsOrderBox = new FbaLogsticsOrderBox();
            switch (i) {
                case 0:
                    serial = "合计";
                    break;
                case 1:
                    serial = "箱重(kg)";
                    break;
                case 2:
                    serial = "箱规长(cm)";
                    break;
                case 3:
                    serial = "箱规宽(cm)";
                    break;
                case 4:
                    serial = "箱规高(cm)";
                    break;
                case 5:
                    serial = "抛重(kg)";
                    break;
                case 6:
                    serial = "单箱采购总价(￥)";
                    break;
                case 7:
                    serial = "追踪编号";
                    break;
            }
            if (i != 0){
                fbaLogsticsOrderBox.setBoxList(boxListMap.get(serial)==null?null:boxListMap.get(serial).toString());
            }
            if (i == 0){
                fbaLogsticsOrderBox.setNumPlanDeliver(fbaLogsticsOrderBoxTol.getNumPlanDeliver());
                fbaLogsticsOrderBox.setNumRealityDeliver(fbaLogsticsOrderBoxTol.getNumRealityDeliver().equals("0")?"":fbaLogsticsOrderBoxTol.getNumRealityDeliver());
                fbaLogsticsOrderBox.setBoxList(fbaLogsticsOrderBoxTol.getBoxList());
            }

            fbaLogsticsOrderBox.setScrapData("1");
            fbaLogsticsOrderBox.setSerial(serial);
            queryList.add(fbaLogsticsOrderBox);
        }
        return queryList;
    }

    private void  addJx(List<FbaLogsticsOrderBox> fbaLogsticsOrderBoxList,FbaLogsticsOrderBox fbaLogsticsOrderBox,Integer type,FbaLogsticsOrderBoxTol fbaLogsticsOrderBoxTol){
        String valueNum = "";
        for (int j = 0; j < fbaLogsticsOrderBoxList.size(); j++) {
            if (type == -1){
                valueNum = fbaLogsticsOrderBox.getNumRealityDeliver();
            }  else if (type == 1){
                valueNum = fbaLogsticsOrderBoxList.get(j).getWeight();
            } else  if (type == 2){
                valueNum = fbaLogsticsOrderBoxList.get(j).getLength();
            }  else  if (type == 3){
                valueNum = fbaLogsticsOrderBoxList.get(j).getWidth();
            } else  if (type == 4){
                valueNum = fbaLogsticsOrderBoxList.get(j).getHeight();
            } else  if (type == 5){
                valueNum = fbaLogsticsOrderBoxList.get(j).getWeightVol();
            } else  if (type == 6){
                valueNum = String.valueOf(fbaLogsticsOrderBoxList.get(j).getPriceSingleBoxReq());
            }else  if (type == 7){
                valueNum = fbaLogsticsOrderBoxList.get(j).getTrackingCode();
            }
            if (type != 0){
                switch (j) {
                    case 0:
                        fbaLogsticsOrderBox.setNumRealityDeliver1(valueNum);
                        break;
                    case 1:
                        fbaLogsticsOrderBox.setNumRealityDeliver2(valueNum);
                        break;
                    case 2:
                        fbaLogsticsOrderBox.setNumRealityDeliver3(valueNum);
                        break;
                    case 3:
                        fbaLogsticsOrderBox.setNumRealityDeliver4(valueNum);
                        break;
                    case 4:
                        fbaLogsticsOrderBox.setNumRealityDeliver5(valueNum);
                        break;
                    case 5:
                        fbaLogsticsOrderBox.setNumRealityDeliver6(valueNum);
                        break;
                    case 6:
                        fbaLogsticsOrderBox.setNumRealityDeliver7(valueNum);
                        break;
                    case 7:
                        fbaLogsticsOrderBox.setNumRealityDeliver8(valueNum);
                        break;
                    case 8:
                        fbaLogsticsOrderBox.setNumRealityDeliver9(valueNum);
                        break;
                    case 9:
                        fbaLogsticsOrderBox.setNumRealityDeliver10(valueNum);
                        break;
                }
            }
        }
        if (type == 0){
            fbaLogsticsOrderBox.setNumPlanDeliver(fbaLogsticsOrderBoxTol.getNumPlanDeliver());
            fbaLogsticsOrderBox.setNumRealityDeliver(fbaLogsticsOrderBoxTol.getNumRealityDeliver().equals("0")?"":fbaLogsticsOrderBoxTol.getNumRealityDeliver());
            fbaLogsticsOrderBox.setNumRealityDeliver1(fbaLogsticsOrderBoxTol.getNumRealityDeliver1().equals("0")?"":fbaLogsticsOrderBoxTol.getNumRealityDeliver1());
            fbaLogsticsOrderBox.setNumRealityDeliver2(fbaLogsticsOrderBoxTol.getNumRealityDeliver2().equals("0")?"":fbaLogsticsOrderBoxTol.getNumRealityDeliver2());
            fbaLogsticsOrderBox.setNumRealityDeliver3(fbaLogsticsOrderBoxTol.getNumRealityDeliver3().equals("0")?"":fbaLogsticsOrderBoxTol.getNumRealityDeliver3());
            fbaLogsticsOrderBox.setNumRealityDeliver4(fbaLogsticsOrderBoxTol.getNumRealityDeliver4().equals("0")?"":fbaLogsticsOrderBoxTol.getNumRealityDeliver4());
            fbaLogsticsOrderBox.setNumRealityDeliver5(fbaLogsticsOrderBoxTol.getNumRealityDeliver5().equals("0")?"":fbaLogsticsOrderBoxTol.getNumRealityDeliver5());
            fbaLogsticsOrderBox.setNumRealityDeliver6(fbaLogsticsOrderBoxTol.getNumRealityDeliver6().equals("0")?"":fbaLogsticsOrderBoxTol.getNumRealityDeliver6());
            fbaLogsticsOrderBox.setNumRealityDeliver7(fbaLogsticsOrderBoxTol.getNumRealityDeliver7().equals("0")?"":fbaLogsticsOrderBoxTol.getNumRealityDeliver7());
            fbaLogsticsOrderBox.setNumRealityDeliver8(fbaLogsticsOrderBoxTol.getNumRealityDeliver8().equals("0")?"":fbaLogsticsOrderBoxTol.getNumRealityDeliver8());
            fbaLogsticsOrderBox.setNumRealityDeliver9(fbaLogsticsOrderBoxTol.getNumRealityDeliver9().equals("0")?"":fbaLogsticsOrderBoxTol.getNumRealityDeliver9());
            fbaLogsticsOrderBox.setNumRealityDeliver10(fbaLogsticsOrderBoxTol.getNumRealityDeliver10().equals("0")?"":fbaLogsticsOrderBoxTol.getNumRealityDeliver10());
        }
    }

}
